/**
 * @description 读取缓存
 * @param {String} key 键
 * @param  value  值,尽量不要传JSON类型
 * @param options
 */
export const set = (
  key: string,
  value: any,
  options: {
    type: StorageType;
    expires?: number;
  } = {
    type: "local",
  }
) => {
  switch (options.type) {
    case "local":
      localStorage.setItem(key, JSON.stringify(value));
      break;
    case "session":
      sessionStorage.setItem(key, JSON.stringify(value));
      break;
    case "cookie":
      break;

    default:
      break;
  }
};

/**
 * @description 读取缓存
 * @param key 键
 * @param type
 */
export const get = (key: string, type: StorageType = "local") => {
  switch (type) {
    case "local":
      localStorage.getItem(key);
      break;
    case "session":
      sessionStorage.getItem(key);
      break;
    case "cookie":
      break;

    default:
      break;
  }
};
